import json
#组合json
class ApiBuild:
    def __init__(self,code,message=None,obj=None):
        self.code=code
        self.message=message
        self.obj=obj

    @staticmethod
    def success():
        msg = ApiBuild(1)
        return json.dumps(msg.__dict__,ensure_ascii=False)

    @staticmethod
    def successWithMessage(message):
        msg = ApiBuild(1,message)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def successWithObject(obj):
        msg = ApiBuild(1,"",obj)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def successWithAll(message,obj):
        msg = ApiBuild(1,message,obj)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def fail(self):
        msg = ApiBuild(0)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def failWithMessage(message):
        msg = ApiBuild(0, message)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def failWithObject(obj):
        msg = ApiBuild(0, "", obj)
        return json.dumps(msg.__dict__, ensure_ascii=False)
    @staticmethod
    def failWithAll(message, obj):
        msg = ApiBuild(0, message, obj)
        return json.dumps(msg.__dict__, ensure_ascii=False)
